﻿using CommunityToolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace DataGridExample;

public partial class ViewModel : ObservableObject
{
    public ObservableCollection<Student> ListOfStudents { get; set; } =
    [
        new Student{ Id=202401, Name="张三", Age=17, IsSelected=false, Gender=GenderType.Men},
        new Student{ Id=202402, Name="李四", Age=18, IsSelected=true, Gender=GenderType.Men},
        new Student{ Id=202403, Name="王五", Age=19, IsSelected=false, Gender=GenderType.Women},
        new Student{ Id=202404, Name="赵六", Age=20, IsSelected=true, Gender=GenderType.Men},
        new Student{ Id=202405, Name="孙七", Age=21, IsSelected=false, Gender=GenderType.Men},
        new Student{ Id=202406, Name="周八", Age=22, IsSelected=true, Gender=GenderType.Women},
        new Student{ Id=202407, Name="吴九", Age=23, IsSelected=false, Gender=GenderType.Men},
    ];
}

/// <summary>
/// 性别
/// </summary>
public enum GenderType
{
    [Description("男")]
    Men,

    [Description("女")]
    Women
}

public partial class Student : ObservableObject
{
    [ObservableProperty]
    private int m_Id;

    [ObservableProperty]
    private string m_Name = string.Empty;

    [ObservableProperty]
    private int m_Age;

    [ObservableProperty]
    private bool m_IsSelected;

    [ObservableProperty]
    private GenderType m_Gender;

    public override string ToString() => $"""
        ID: {Id}
        Name: {Name}
        Age: {Age}
        IsSelected: {IsSelected}
        GenderType: {Gender}
        """;
}
